import { defHttp } from '/@/utils/http/axios';
import { CodeGenConfigParams, GenCodePreviewModel } from '/@/api/gen/model/CodeGenModel';

enum Api {
  // 代码生成接口
  PublicApi = '/gen/generate',
  CodeGenInnerApi = `/gen/generate/inner`,
  CodeGenZipApi = `/gen/generate/zip`,
  CodePreviewApi = `/gen/generate/preview`,
}

/**
 * @description:  获取数据源列表
 * @param params
 * @returns
 */
export const codeGenInner = (params?: CodeGenConfigParams) =>
  defHttp.post<boolean>({ url: Api.CodeGenInnerApi, params });
export const codeGenZip = (params?: CodeGenConfigParams) =>
  defHttp.post(
    { url: Api.CodeGenZipApi, params, responseType: 'blob' },
    { isReturnNativeResponse: true },
  );
export const codePreview = (params?: CodeGenConfigParams) =>
  defHttp.post<GenCodePreviewModel>({ url: Api.CodePreviewApi, params });
